<!-- This comment will put IE 6, 7 and 8 in quirks mode -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>shark::TwoPointStepSizeAdaptation Class Reference</title>
<script type="text/javaScript" src="search/search.js"></script>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3.0.1/es5/tex-mml-chtml.js"></script>
<script src="../../mlstyle.js"></script>
<link href="../css/besser.css" rel="stylesheet" type="text/css"/>
</head>
<!-- pretty cool: each body gets an id tag which is the basename of the web page  -->
<!--              and allows for page-specific CSS. this is client-side scripted, -->
<!--              so the id will not yet show up in the served source code -->
<script type="text/javascript">
    jQuery(document).ready(function () {
        var url = jQuery(location).attr('href');
        var pname = url.substr(url.lastIndexOf("/")+1, url.lastIndexOf(".")-url.lastIndexOf("/")-1);
        jQuery('#this_url').html('<strong>' + pname + '</strong>');
        jQuery('body').attr('id', pname);
    });
</script>
<body>
    <div id="shark_old">
        <div id="wrap">
            <div id="header">
                <div id="site-name"><a href="../../sphinx_pages/build/html/index.html">Shark machine learning library</a></div>
                <ul id="nav">
                    <li >
                        <a href="../../sphinx_pages/build/html/rest_sources/installation.html">Installation</a>
                    </li>
		    <li >
                        <a href="../../sphinx_pages/build/html/rest_sources/tutorials/tutorials.html">Tutorials</a>
                    </li>
		    <li >
                        <a href="../../sphinx_pages/build/html/rest_sources/benchmark.html">Benchmarks</a>
                    </li>
                    <li class="active">
                        <a href="classes.html">Documentation</a>
                        <ul>
                            <li class="first"></li>
                            <li><a href="../../sphinx_pages/build/html/rest_sources/quickref/quickref.html">Quick references</a></li>
                            <li><a href="classes.html">Class list</a></li>
                            <li class="last"><a href="group__shark__globals.html">Global functions</a></li>
                        </ul>
                    </li>
                </ul>
            </div>
        </div>
    </div>
<div id="doxywrapper">
<!--
    <div id="global_doxytitle">Doxygen<br>Documentation:</div>
-->
    <div id="navrow_wrapper">
<!-- Generated by Doxygen 1.9.8 -->
<div id="nav-path" class="navpath">
  <ul>
<li class="navelem"><a class="el" href="namespaceshark.html">shark</a></li><li class="navelem"><a class="el" href="classshark_1_1_two_point_step_size_adaptation.html">TwoPointStepSizeAdaptation</a></li>  </ul>
</div>
</div><!-- top -->
<div class="header">
  <div class="summary">
<a href="classshark_1_1_two_point_step_size_adaptation-members.html">List of all members</a> &#124;
<a href="#pub-methods">Public Member Functions</a>  </div>
  <div class="headertitle"><div class="title">shark::TwoPointStepSizeAdaptation Class Reference</div></div>
</div><!--header-->
<div class="contents">

<p>Step size adaptation based on the success of the new population compared to the old.  
 <a href="classshark_1_1_two_point_step_size_adaptation.html#details">More...</a></p>

<p><code>#include &lt;<a class="el" href="_two_point_step_size_adaptation_8h_source.html">shark/Algorithms/DirectSearch/Operators/TwoPointStepSizeAdaptation.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a id="pub-methods" name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:afeae0541cca518119296e0d33927aa07" id="r_afeae0541cca518119296e0d33927aa07"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_two_point_step_size_adaptation.html#afeae0541cca518119296e0d33927aa07">TwoPointStepSizeAdaptation</a> ()</td></tr>
<tr class="separator:afeae0541cca518119296e0d33927aa07"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a2af42fba89576310fd19e7fc45ca4080" id="r_a2af42fba89576310fd19e7fc45ca4080"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_two_point_step_size_adaptation.html#a2af42fba89576310fd19e7fc45ca4080">stepSize</a> () const</td></tr>
<tr class="separator:a2af42fba89576310fd19e7fc45ca4080"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af20f6e58a5564dd83f8a770b99fb8124" id="r_af20f6e58a5564dd83f8a770b99fb8124"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_two_point_step_size_adaptation.html#af20f6e58a5564dd83f8a770b99fb8124">setAlphaStep</a> (double alphaStep)</td></tr>
<tr class="separator:af20f6e58a5564dd83f8a770b99fb8124"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a6d2d6a051012db295c5fe2ef91c6d2dc" id="r_a6d2d6a051012db295c5fe2ef91c6d2dc"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_two_point_step_size_adaptation.html#a6d2d6a051012db295c5fe2ef91c6d2dc">setLearningRate</a> (double learningRate)</td></tr>
<tr class="separator:a6d2d6a051012db295c5fe2ef91c6d2dc"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:aa32f71d5a7bcf74aed6ac6e89a4885d6" id="r_aa32f71d5a7bcf74aed6ac6e89a4885d6"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_two_point_step_size_adaptation.html#aa32f71d5a7bcf74aed6ac6e89a4885d6">init</a> (double initialStepSize)</td></tr>
<tr class="memdesc:aa32f71d5a7bcf74aed6ac6e89a4885d6"><td class="mdescLeft">&#160;</td><td class="mdescRight">Initializes a new trial by setting the initial step size and resetting the internal values.  <br /></td></tr>
<tr class="separator:aa32f71d5a7bcf74aed6ac6e89a4885d6"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a65f48fafa82bd1b7a3f7e0d44137d139" id="r_a65f48fafa82bd1b7a3f7e0d44137d139"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_two_point_step_size_adaptation.html#a65f48fafa82bd1b7a3f7e0d44137d139">setStepSize</a> (double <a class="el" href="classshark_1_1_two_point_step_size_adaptation.html#a2af42fba89576310fd19e7fc45ca4080">stepSize</a>)</td></tr>
<tr class="separator:a65f48fafa82bd1b7a3f7e0d44137d139"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab05207bccc1bacfaa163727a239099b2" id="r_ab05207bccc1bacfaa163727a239099b2"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classshark_1_1_two_point_step_size_adaptation.html#ab05207bccc1bacfaa163727a239099b2">update</a> (<a class="el" href="namespaceshark.html#ac9bc8d3d1ae0af07b6957a638ce5f01b">SingleObjectiveFunction</a> const &amp;f, RealVector const &amp;point, RealVector const &amp;direction)</td></tr>
<tr class="memdesc:ab05207bccc1bacfaa163727a239099b2"><td class="mdescLeft">&#160;</td><td class="mdescRight">updates the step size using the newly sampled population  <br /></td></tr>
<tr class="separator:ab05207bccc1bacfaa163727a239099b2"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>Step size adaptation based on the success of the new population compared to the old. </p>
<p>This is the step size adaptation algorithm as proposed in Ilya Loshchilov, "A Computationally Efficient Limited Memory CMA-ES for Large Scale Optimization"</p>
<p>It ranks the old and new population together and checks whether the mean rank of the new population is lower than the old one in this combined population. If this is true, the step size is increased in an exponential fashion. More formally, let \( r_t(i) \) be the rank of the i-th individual in the current population in the combined ranking and \( r_{t-1}(i) \) the rank of the i-th previous individual. Then we have </p><p class="formulaDsp">
\[ z_t \leftarrow \frac 1 {\lamba^2} \sum_i^{\lambda} r_{t-1}(i) - r_t(i) - z*\]
</p>
<p> where \( z* \) is a target success value, which defaults to 0.25 this statistic is stabilised using an exponential average: </p><p class="formulaDsp">
\[ s_t \leftarrow (1-c)*s_{t-1} + c*z_t \]
</p>
<p> where the learning rate c defaults to 0.3 finally we adapt the step size sigma by </p><p class="formulaDsp">
\[ \sigma_t = \sigma_{t-1} exp(s_t/d) \]
</p>
<p> where the damping factor d defaults to 1 </p>

<p class="definition">Definition at line <a class="el" href="_two_point_step_size_adaptation_8h_source.html#l00053">53</a> of file <a class="el" href="_two_point_step_size_adaptation_8h_source.html">TwoPointStepSizeAdaptation.h</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="afeae0541cca518119296e0d33927aa07" name="afeae0541cca518119296e0d33927aa07"></a>
<h2 class="memtitle"><span class="permalink"><a href="#afeae0541cca518119296e0d33927aa07">&#9670;&#160;</a></span>TwoPointStepSizeAdaptation()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">shark::TwoPointStepSizeAdaptation::TwoPointStepSizeAdaptation </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="_two_point_step_size_adaptation_8h_source.html#l00055">55</a> of file <a class="el" href="_two_point_step_size_adaptation_8h_source.html">TwoPointStepSizeAdaptation.h</a>.</p>

</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="aa32f71d5a7bcf74aed6ac6e89a4885d6" name="aa32f71d5a7bcf74aed6ac6e89a4885d6"></a>
<h2 class="memtitle"><span class="permalink"><a href="#aa32f71d5a7bcf74aed6ac6e89a4885d6">&#9670;&#160;</a></span>init()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void shark::TwoPointStepSizeAdaptation::init </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>initialStepSize</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Initializes a new trial by setting the initial step size and resetting the internal values. </p>

<p class="definition">Definition at line <a class="el" href="_two_point_step_size_adaptation_8h_source.html#l00070">70</a> of file <a class="el" href="_two_point_step_size_adaptation_8h_source.html">TwoPointStepSizeAdaptation.h</a>.</p>

</div>
</div>
<a id="af20f6e58a5564dd83f8a770b99fb8124" name="af20f6e58a5564dd83f8a770b99fb8124"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af20f6e58a5564dd83f8a770b99fb8124">&#9670;&#160;</a></span>setAlphaStep()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void shark::TwoPointStepSizeAdaptation::setAlphaStep </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>alphaStep</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="_two_point_step_size_adaptation_8h_source.html#l00061">61</a> of file <a class="el" href="_two_point_step_size_adaptation_8h_source.html">TwoPointStepSizeAdaptation.h</a>.</p>

</div>
</div>
<a id="a6d2d6a051012db295c5fe2ef91c6d2dc" name="a6d2d6a051012db295c5fe2ef91c6d2dc"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a6d2d6a051012db295c5fe2ef91c6d2dc">&#9670;&#160;</a></span>setLearningRate()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void shark::TwoPointStepSizeAdaptation::setLearningRate </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>learningRate</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="_two_point_step_size_adaptation_8h_source.html#l00065">65</a> of file <a class="el" href="_two_point_step_size_adaptation_8h_source.html">TwoPointStepSizeAdaptation.h</a>.</p>

</div>
</div>
<a id="a65f48fafa82bd1b7a3f7e0d44137d139" name="a65f48fafa82bd1b7a3f7e0d44137d139"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a65f48fafa82bd1b7a3f7e0d44137d139">&#9670;&#160;</a></span>setStepSize()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void shark::TwoPointStepSizeAdaptation::setStepSize </td>
          <td>(</td>
          <td class="paramtype">double&#160;</td>
          <td class="paramname"><em>stepSize</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="_two_point_step_size_adaptation_8h_source.html#l00075">75</a> of file <a class="el" href="_two_point_step_size_adaptation_8h_source.html">TwoPointStepSizeAdaptation.h</a>.</p>

<p class="reference">References <a class="el" href="classshark_1_1_two_point_step_size_adaptation.html#a2af42fba89576310fd19e7fc45ca4080">stepSize()</a>.</p>

</div>
</div>
<a id="a2af42fba89576310fd19e7fc45ca4080" name="a2af42fba89576310fd19e7fc45ca4080"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a2af42fba89576310fd19e7fc45ca4080">&#9670;&#160;</a></span>stepSize()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">double shark::TwoPointStepSizeAdaptation::stepSize </td>
          <td>(</td>
          <td class="paramname"></td><td>)</td>
          <td> const</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p class="definition">Definition at line <a class="el" href="_two_point_step_size_adaptation_8h_source.html#l00057">57</a> of file <a class="el" href="_two_point_step_size_adaptation_8h_source.html">TwoPointStepSizeAdaptation.h</a>.</p>

<p class="reference">Referenced by <a class="el" href="classshark_1_1_two_point_step_size_adaptation.html#a65f48fafa82bd1b7a3f7e0d44137d139">setStepSize()</a>.</p>

</div>
</div>
<a id="ab05207bccc1bacfaa163727a239099b2" name="ab05207bccc1bacfaa163727a239099b2"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab05207bccc1bacfaa163727a239099b2">&#9670;&#160;</a></span>update()</h2>

<div class="memitem">
<div class="memproto">
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void shark::TwoPointStepSizeAdaptation::update </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="namespaceshark.html#ac9bc8d3d1ae0af07b6957a638ce5f01b">SingleObjectiveFunction</a> const &amp;&#160;</td>
          <td class="paramname"><em>f</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">RealVector const &amp;&#160;</td>
          <td class="paramname"><em>point</em>, </td>
        </tr>
        <tr>
          <td class="paramkey"></td>
          <td></td>
          <td class="paramtype">RealVector const &amp;&#160;</td>
          <td class="paramname"><em>direction</em>&#160;</td>
        </tr>
        <tr>
          <td></td>
          <td>)</td>
          <td></td><td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>updates the step size using the newly sampled population </p>
<p>The offspring is assumed to be ordered in ascending order by their penalizedFitness (this is the same as ordering by the unpenalized fitness in an unconstrained setting) </p>

<p class="definition">Definition at line <a class="el" href="_two_point_step_size_adaptation_8h_source.html#l00083">83</a> of file <a class="el" href="_two_point_step_size_adaptation_8h_source.html">TwoPointStepSizeAdaptation.h</a>.</p>

<p class="reference">References <a class="el" href="classshark_1_1_abstract_objective_function.html#a751c175270f6d6f0bcc1200f333c0045">shark::AbstractObjectiveFunction&lt; PointType, ResultT &gt;::eval()</a>.</p>

</div>
</div>
<hr/>The documentation for this class was generated from the following file:<ul>
<li>include/shark/Algorithms/DirectSearch/Operators/<a class="el" href="_two_point_step_size_adaptation_8h_source.html">TwoPointStepSizeAdaptation.h</a></li>
</ul>
</div><!-- contents -->
</div>
</body>
</html>
